﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DingHeng.TransportationManagement.DataAccess;
using DingHeng.TransportationManagement.Entity;

namespace DingHeng.TransportationManagement.Business
{
    public class UserBiz
    {
        public List<User> LoadActiveUsers()
        {
            using (UserDataAccess uda = new UserDataAccess())
            {
                return uda.LoadByCondition(u => u.IsActive == true).ToList();
            }
        }
        public User Login(string account, string password)
        {
            string accountTemp = account.ToLower();
            using (UserDataAccess uda = new UserDataAccess())
            {
                return uda.LoadByCondition(u => u.IsActive == true && u.Account.ToLower() == accountTemp && u.Password == password).FirstOrDefault();
            }
        }
        public User LoadById(Guid id)
        {
            using (UserDataAccess uda = new UserDataAccess())
            {
                return uda.LoadByCondition(u => u.IsActive == true && u.ID==id).FirstOrDefault();
            }
        }
    }
}
